Scientific Linux 6
Sponsored Link

Configure RAID 1
2011/05/10
  Configure RAID 1. This example set /home for it.

It needs at least 2 disks that have enough free area, if your computer does not have such disks, add disks in your computer, or configure iSCSI to attach network storage.

[1] Create a RAID partition on each disks. See here to create a partiton. The example in the link creates LVM partiton, but be careful, create a RAID partiton on here. The partition type of RAID is just "fd". Specify it for partition type. After creating RAID partition, the status of disks is just like follows.
[root@dlp ~]#
sfdisk -l /dev/sdb


Disk /dev/sdb: 20886 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device
  Boot
Start
End
#cyls
#blocks
Id
System

/dev/sdb1
0+
20885
20886-
167766763+
fd
Linux raid autodetect

/dev/sdb2
0
-
0
0
0
Empty

/dev/sdb3
0
-
0
0
0
Empty

/dev/sdb4
0
-
0
0
0
Empty
[2] Configure RAID 1
[root@dlp ~]#
mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1


mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device. If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array?
y

mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@dlp ~]#
vi /etc/mdadm.conf


# mdadm.conf written out by anaconda
MAILADDR root
AUTO +imsm +1.x -all
# add

DEVICE /dev/sd[a-z]*
ARRAY /dev/md0 level=raid1 devices=/dev/sdb1,/dev/sdc1


[root@dlp ~]#
cat /proc/mdstat
# show status ( it's OK if it shows "[UU]" )

Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
    104855127 blocks super 1.2 [2/2] [UU]
    [==========>..........] resync = 50.1% (52600064/104855127) finish=4.2min speed=206060K/sec

unused devices: <none>

# after few minutes later, syncronizeing will complete and the status turns like follows

[root@dlp ~]#
cat /proc/mdstat

Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
    104855127 blocks super 1.2 [2/2] [UU]

unused devices: <none>
[3] Configuration completes to create a file system in RAID device and mount /home on it.
[root@dlp ~]#
pvcreate /dev/md0

  Physical volume "/dev/md0" successfully created
[root@dlp ~]#
vgcreate vg_home /dev/md0

  Volume group "vg_home" successfully created
[root@dlp ~]#
lvcreate -L 50G -n lv_home vg_home

  Logical volume "lv_home" created
[root@dlp ~]#
mkfs -t ext4 /dev/vg_home/lv_home

[root@dlp ~]#
mount /dev/vg_home/lv_home /mnt

[root@dlp ~]#
cp -pR /home/* /mnt/

[root@dlp ~]#
umount /mnt

[root@dlp ~]#
mount /dev/vg_home/lv_home /home

[root@dlp ~]#
df -h

Filesystem
1M-blocks
Used
Available
Use%
Mounted on

/dev/mapper/vg_dlp-lv_root
20G
6.9G
12G
37%
/

tmpfs
3.9G
0
3.9G
0%
/dev/shm

/dev/sda1
485M
34M
426M
8%
/boot

/dev/mapper/vg_home-lv_home
50G
182M
47G
1%
/home

[root@dlp ~]#
vi /etc/fstab


# add RAID ARRAY

/dev/mapper/vg_home-lv_home
/home
ext4
defaults
1 2
[4] Start mdmonitor to monitor RAID ARRAY
[root@dlp ~]#
/etc/rc.d/init.d/mdmonitor start

Starting mdmonitor:
[ OK ]

[root@dlp ~]#
chkconfig mdmonitor on
[5] If a hard drive in RAID ARRAY would be Failure, re-configure RAID 1 like follows.
# the status in failure is like follows

[root@dlp ~]#
cat /proc/mdstat

Personalities : [raid1]
md0 : active (auto-read-only) raid1 sdb1[0]
    104855127 blocks super 1.2 [2/1] [U_]

unused devices: <none>

# change to new disk and create a raidautodetect partition on it again

# next, do like follows

[root@dlp ~]#
mdadm --manage /dev/md0 --add /dev/sdc1
 
# add new partition in RAID ARRAY

mdadm: added /dev/sdc1

[root@dlp ~]#
cat /proc/mdstat

# syncronizing starts

Personalities : [raid1]
md0 : active raid1 sdc1[2] sdb1[0]
    104855127 blocks super 1.2 [2/1] [U_]
    [>....................] recovery = 4.9% (5200000/104855127) finish=7.9min speed=208000K/sec

unused devices: <none>

# after few minutes later, syncronizeing will complete and the status turns like follows.

[root@dlp ~]#
cat /proc/mdstat

Personalities : [raid1]
md0 : active raid1 sdc1[2] sdb1[0]
    104855127 blocks super 1.2 [2/2] [UU]

unused devices: <none>
 
Tweet